package com.zhm.springcloud.service.impl;

import cn.hutool.core.lang.UUID;
import com.zhm.springcloud.service.MyMessageProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;

/**
 * Date： 2021/3/16 22:18
 *
 * @author ZHM
 */
@EnableBinding(Source.class) // 定义消息的推送管道
@Slf4j
public class MyMessageProviderImpl implements MyMessageProvider {

    @Resource
    private MessageChannel output; // 消息发送管道

    @Override
    public String send() {
        String serial = UUID.fastUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        log.info("发送流水消息：----->{}",serial);
        return serial;
    }
}
